package com.qiao.glod.ui.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Qiao on 2016/4/7.
 * function：
 */
public abstract class QFragment extends Fragment {
    private static final String TAG = "QFragment";
    protected View mRootView;
    protected Context context;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mRootView = inflater.inflate(generateResId(), container, false);
        return mRootView;
    }

    protected abstract int generateResId();

    protected <T extends View> T findView(int resId) {
        return (T) mRootView.findViewById(resId);
    }

    public void finish(){
        getActivity().finish();
    }
}
